import java.util.HashMap;

public class FlyweightFactory {
    //享元池
    private HashMap<String,Flyweight> flyweights =
            new HashMap<String,Flyweight>();
    public  Flyweight getFlywight(String key){
        Flyweight flyweight;

        if(flyweights.containsKey(key)){
            flyweight = flyweights.get(key);
        }else{
            flyweight = new ConcreteFlyweight(key);
            flyweights.put(key,flyweight);
        }

        return flyweight;

    }

}
